package com.ys.day28.socket通信方式;

import java.util.Objects;

/**
 * 描述: 歌曲枚举类
 *
 * @author CodeYang
 * @version 2021/1/8 21:48
 */
public enum SongEnum {
    SONG1(1,"歌曲1","歌词1----"),SONG2(2,"歌曲2","歌词2---"),SONG3(3,"歌曲3","歌词3--");


    private int id;
    private String name;
    private String word;

    SongEnum() {

    }

    SongEnum(int id, String name, String word) {
        this.id = id;
        this.name = name;
        this.word = word;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWord() {
        return word;
    }

    public void setWord(String word) {
        this.word = word;
    }

    /**
     * 根据歌曲名称返回歌词
     * @return word
     */
    public static String getWordByname  (String name) {
        // 遍历SongEnum的集合
        for (SongEnum value : SongEnum.values()) {
            if (Objects.equals(value.getName(), name)) {
                // 返回对应的歌词
                return value.getWord();
            }
        }
        return null;
    }
}
